home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gui / muibuilderv11.lha / muibuilder / mb / e / click_locale / Click.e < prev    next >
Text File  |  1994-03-15  |  7KB  |  195 lines

  1. /******************************************************************************
  2.     Here is an example of an "environnement file". All you have to do, si to
  3. fill it with :
  4.     - some constant declarations and array initialisations for localisation
  5.     - use MUIBuilder+GenCodeE to generate the create_app() function
  6.     - add the code for your application !!!
  7. ******************************************************************************/
  8.  
  9. OPT OSVERSION=37
  10.  
  11.     /* Module definitions */
  12. MODULE 'muimaster', 'libraries/mui'
  13. MODULE 'utility/tagitem', 'utility/hooks'
  14. MODULE 'intuition/classes', 'intuition/classusr'
  15. MODULE 'locale', 'libraries/locale'
  16.  
  17.     /* Error handling */
  18. ENUM NO_LIBRARY, MUI_APPLICATION_FAILURE
  19. RAISE   NO_LIBRARY              IF OpenLibrary()=NIL,
  20.         MUI_APPLICATION_FAILURE IF Mui_NewObjectA()=NIL
  21.  
  22.     /* Object definitions */
  23. OBJECT fc_type
  24.     id  :LONG
  25.     str :LONG
  26. ENDOBJECT
  27.  
  28.     /* Constant definitions */
  29. CONST MUI_TRUE = 1
  30.         /******************************************
  31.             Add here some constant declarations
  32.             for localisation.
  33.         ******************************************/
  34. CONST MSG_AppDescription = 0
  35. CONST MSG_WI_try = 1
  36. CONST MSG_TX_label_0 = 2
  37. CONST MSG_BT_1stbutton = 3
  38. CONST MSG_BT_2ndbutton = 4
  39. CONST MSG_BT_3rdbutton = 5
  40.  
  41.     /* Global variables */
  42. DEF catalog_Click:PTR TO catalog
  43. DEF array_Click[6]:ARRAY OF fc_type        /* Update array size */
  44. /*MUIB*/ DEF app, wi_try, tx_label_0, bt_1stbutton, bt_2ndbutton, bt_3rdbutton
  45. /*MUIB*/ DEF stR_TX_label_0 : PTR TO CHAR
  46.  
  47.  
  48.     /* Main procedure */
  49. PROC main() HANDLE
  50.     DEF signal, result_DoMethod, running = TRUE
  51.  
  52.     localebase := OpenLibrary('locale.library', 0)
  53.     muimasterbase := OpenLibrary('muimaster.library', 0)
  54.     open_Click_catalog(NIL, NIL)
  55.     create_app()
  56.  
  57.     /* Notify : close gadget => end of application */
  58.     doMethod( wi_try, [ MUIM_Notify, MUIA_Window_CloseRequest, MUI_TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit ] )
  59.  
  60.     /* Open the window */
  61.     set( wi_try, MUIA_Window_Open , MUI_TRUE )
  62.  
  63.     WHILE running
  64.         result_DoMethod := doMethod( app, [ MUIM_Application_Input, {signal} ] )
  65.         SELECT result_DoMethod
  66.             CASE MUIV_Application_ReturnID_Quit
  67.                 running := FALSE
  68.         ENDSELECT
  69.         IF (running AND signal) THEN Wait( signal )
  70.     ENDWHILE
  71.  
  72.     Mui_DisposeObject( app )
  73.     close_Click_catalog()
  74.     CloseLibrary( muimasterbase )
  75.     CloseLibrary( localebase )
  76.  
  77. EXCEPT
  78.     SELECT exception
  79.         CASE NO_LIBRARY
  80.         CASE MUI_APPLICATION_FAILURE
  81.     ENDSELECT
  82. ENDPROC
  83.  
  84.  
  85.     /* Procedure generated by GenCodeE which creates your application */
  86. PROC create_app()
  87.     stR_TX_label_0 := get_Click_string( MSG_TX_label_0 )
  88.  
  89.     app := ApplicationObject,
  90.         MUIA_Application_Author, 'Eric Totel',
  91.         MUIA_Application_Base, 'CLICK',
  92.         MUIA_Application_Title, 'Click',
  93.         MUIA_Application_Version, '$VER : Click 1.0',
  94.         MUIA_Application_Copyright, 'Eric Totel 1994',
  95.         MUIA_Application_Description, get_Click_string( MSG_AppDescription ),
  96.         SubWindow, wi_try := WindowObject,
  97.             MUIA_Window_Title, get_Click_string( MSG_WI_try ),
  98.             MUIA_Window_ID, MAKE_ID( "0", "W", "I", "N" ),
  99.             WindowContents, GroupObject,
  100.                 Child, tx_label_0 := TextObject,
  101.                     MUIA_Background, 131,
  102.                     MUIA_Text_Contents, stR_TX_label_0,
  103.                     MUIA_Text_SetMax, 0,
  104.                     MUIA_Text_SetMin, 1,
  105.                     MUIA_Frame, 9,
  106.                 End,
  107.                 Child, GroupObject,
  108.                     MUIA_Group_Horiz, MUI_TRUE,
  109.                     MUIA_Group_SameWidth, MUI_TRUE,
  110.                     Child, bt_1stbutton := et_key_button( get_Click_string( MSG_BT_1stbutton ) ),
  111.                     Child, bt_2ndbutton := et_key_button( get_Click_string( MSG_BT_2ndbutton ) ),
  112.                     Child, bt_3rdbutton := et_key_button( get_Click_string( MSG_BT_3rdbutton ) ),
  113.                 End,
  114.             End,
  115.         End,
  116.     End
  117. ENDPROC
  118.  
  119.  
  120.     /* DoMethod() function */
  121. PROC doMethod( obj:PTR TO object, msg:PTR TO msg )
  122.  
  123.     DEF h:PTR TO hook, o:PTR TO object, dispatcher
  124.  
  125.     IF obj
  126.         o := obj-SIZEOF object     /* instance data is to negative offset */
  127.         h := o.class
  128.         dispatcher := h.entry      /* get dispatcher from hook in iclass */
  129.         MOVEA.L h,A0
  130.         MOVEA.L msg,A1
  131.         MOVEA.L obj,A2           /* probably should use CallHookPkt, but the */
  132.         MOVEA.L dispatcher,A3    /*   original code (DoMethodA()) doesn't. */
  133.         JSR (A3)                 /* call classDispatcher() */
  134.         MOVE.L D0,o
  135.         RETURN o
  136.     ENDIF
  137.  
  138. ENDPROC NIL
  139.  
  140.  
  141.     /* Extended KeyButton for localized buttons */
  142. PROC et_key_button( text:PTR TO CHAR ) RETURN KeyButton( (text+3), text[1] )
  143.  
  144.  
  145.     /* An easy OpenCatalog() function */
  146. PROC open_Click_catalog(loc:PTR TO locale, language:PTR TO CHAR)
  147.     DEF tag, tagarg, dummy_var = 0
  148.  
  149.         /******************************************
  150.             Add here some array initialisations
  151.             for localisation.
  152.         ******************************************/
  153.     array_Click[dummy_var].id := MSG_AppDescription; array_Click[dummy_var++].str := 'just a demo !!!'
  154.     array_Click[dummy_var].id := MSG_WI_try; array_Click[dummy_var++].str := 'Click !!!'
  155.     array_Click[dummy_var].id := MSG_TX_label_0; array_Click[dummy_var++].str := '\e8\ecClick on buttons'
  156.     array_Click[dummy_var].id := MSG_BT_1stbutton; array_Click[dummy_var++].str := '_1 Button 1'
  157.     array_Click[dummy_var].id := MSG_BT_2ndbutton; array_Click[dummy_var++].str := '_2 Button 2'
  158.     array_Click[dummy_var].id := MSG_BT_3rdbutton; array_Click[dummy_var++].str := '_3 Button 3'
  159.  
  160.     IF (localebase AND (catalog_Click = NIL))
  161.         IF language
  162.             tag := OC_LANGUAGE
  163.             tagarg := language
  164.         ELSE
  165.             tag:= TAG_IGNORE
  166.         ENDIF
  167.  
  168.         catalog_Click := OpenCatalogA(loc, 'Click.catalog',
  169.                                             [   OC_BUILTINLANGUAGE, 'english',  /* Update built-in language */
  170.                                                 tag, tagarg,
  171.                                                 OC_VERSION, 0,                  /* Update catalog version number */
  172.                                                 TAG_DONE    ])
  173.     ENDIF
  174. ENDPROC
  175.     
  176.                                 
  177.     /* An easy CloseCatalog() function  */
  178. PROC close_Click_catalog()
  179.  
  180.     IF localebase THEN CloseCatalog( catalog_Click )
  181.     catalog_Click := NIL
  182. ENDPROC
  183.  
  184.  
  185.     /* A GetString() function for localized strings */
  186. PROC get_Click_string( strnum )
  187.     DEF defaultstr:PTR TO CHAR, i = 0
  188.  
  189.         /* Fill the 2 (i < ?) tests by the array size */
  190.     WHILE ((i < 6) AND (array_Click[i].id <> strnum)) DO INC i
  191.     defaultstr := IF (i < 6) THEN array_Click[i].str ELSE NIL
  192.  
  193. ENDPROC IF catalog_Click THEN GetCatalogStr( catalog_Click, strnum, defaultstr ) ELSE defaultstr
  194.  
  195.